package factory

import "fmt"

// 简单工厂

type Animal interface {
	Say()
}

type Dog struct {
	name string
}

func NewDog(name string) *Dog {
	return &Dog{name: name}
}

func (d Dog) Say() {
	fmt.Println("旺旺....", d.name)
}

type Cat struct {
	name string
}

func NewCat(name string) *Cat {
	return &Cat{name: name}
}

func (c Cat) Say() {
	fmt.Println("喵喵...", c.name)
}

func SimpleFoctory(name string) Animal {
	if name == "cat" {
		return NewCat(name)
	}
	return NewDog(name)
}

// 工厂模式

type SaveMethod interface {
	Create() MemorySave
}

type MemorySave interface {
	Save()
}

type RDBSave struct{}
type AOFSave struct{}

// 抽象工厂

// Save
type HtmlOrder struct{}
type HtmlOrderLine struct{}

type XMLOrder struct{}
type XMLOrderLine struct{}

type OrderAction interface {
	SaveOrder()
}

type OrderLineAction interface {
	SaveOrderLine()
}

type OrderCenter interface {
	CreateOrder() OrderAction
	CreateOrderLine() OrderLineAction
}

type OrderHtmlFactory struct{}
type OrderXMLFactory struct{}
